//
//  DM_OrmSQLCreateTableBuidler.swift
//  构建者模式_ORM_SWIFT
//
//  Created by 王苏进 on 17/5/17.
//  Copyright © 2017年 macOS. All rights reserved.
//

import UIKit

class DM_OrmSQLCreateTableBuidler: DM_SQLCreateTableBuilder {
    
    
    func createTable(orm: DM_Orm) -> DM_OrmSQLCreateTableBuidler {
        
        
        var colums = [String : String]()
        
      
        //添加字段
        //添加主键
     
        if let c = orm.key?.column {
            colums[c] = getColumnType(propertyType: (orm.key?.propertyType)!)
        }
       
        
        //添加普通属性
        for item in orm.items {
            colums[item.column] = getColumnType(propertyType: item.propertyType)
        }
        
        
        return (self.create().talbe(orm.tableName) as! DM_SQLCreateTableBuilder).columns_all(colums) as!DM_OrmSQLCreateTableBuidler
    }
    
    

}
